<template>
	<view>
		<u-popup :show="screen_show" @close="close" @open="open" mode="top">
			<view>
				<view class="screen_box">
					<text>支付方式</text>
					<view class="screen_option">
						<text class="on">全部</text>
						<text>刷卡</text>
						<text>闪付</text>
						<text>扫码</text>
					</view>
					<text>结算类型</text>
					<view class="screen_option">
						<text class="on">全部</text>
						<text>T+1</text>
						<text>T+0</text>
						<text>T+X</text>
					</view>
					<text>交易金额区间</text>
					<view class="screen_option">
						<input type="text" placeholder="最小值"> 至 <input type="text" placeholder="最大值">
					</view>
				</view>
				<view class="btn">
					<text>重置</text>
					<text>确认</text>
				</view>
			</view>
		</u-popup>
		<u-sticky bgColor="#fff">
			<view class="search">
				<u-search :showAction="true" actionText="搜索" v-model="search" :animation="true"
					@custom="searchfun"></u-search>
			</view>
			<!-- <view class="sticky_screen">
				<text @click="dateChange(1)">昨天</text>
				<text @click="dateChange(2)">近7天</text>
				<text @click="dateChange(3)">当月</text>
			</view> -->
		</u-sticky>
		<view class="detailed_box">
			<view class="detailed_card">
				<view class="detailed_card_title">
					<u-icon size="18" color="#ffffff" name="red-packet"></u-icon>
					<text class="card">累计交易</text>
				</view>
				<h2>{{all_total}}</h2>
			</view>
			<view v-if="all_num > 0" class="detailed_list">
				<view class="detailed_item" v-for="(item, index) in data" :key="index">
					<view class="">
						<text>{{item.name}}</text>
						<text>{{item.money}}</text>
					</view>
					<u-line></u-line>
					<view class="detailed_item_text">
						<text>{{item.sn}}</text>
						<text>{{item.remarks}}</text>
					</view>
					<u-line dashed></u-line>
					<view class="detailed_item_text">
						<text>{{item.tran_type==1?'贷记':'扫码'}}</text>
						<text>{{item.trading_time_text}}</text>
					</view>
				</view>
			</view>
			<u-empty v-else mode="list" icon="@/static/Empty/data_null.png">
			</u-empty>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: [],
				page: 1,
				bottom: true,
				all_total: '0.00',
				all_num: 0,
				date: null,
				type: 1,
				product_id: null,
				team_id: null,
				tran_type: null,
				screen_show: false,
				search: null
			}
		},
		onLoad(e) {
			this.date = e.date
			this.product_id = e.product_id
			this.team_id = e.team_id
			this.tran_type = e.tran_type
			uni.setNavigationBarTitle({
				title: '交易详情'
			})
			this.loadTotal()
			this.loadData()
		},
		//下拉刷新
		onReachBottom() {
			// if (this.bottom == true) {
			// 	this.page += 1
			// 	this.loadData()
			// }
		},
		methods: {
			open() {},
			close() {
				this.screen_show = false
			},
			searchfun() {
				this.loadTotal()
				this.loadData()
			},
			dateChange(type) {
				this.type = type
				this.page = 1
				this.data = []
				this.bottom = true
				this.loadTotal()
				this.loadData()
			},
			//统计
			async loadTotal() {
				const userinfo = uni.getStorageSync('userinfo');
				const {
					data: res
				} = await this.$myHttp5({
					url: 'Datas/getTranDetailTotal5',
					data: {
						product_id: this.product_id,
						date: this.date,
						type: this.type,
						search: this.search,
						team_id: this.team_id,
						tran_type: this.tran_type
					},
					header: {
						'token': userinfo.token
					},
				});
				if (res.code == 1) {
					// uni.hideLoading()
					this.all_total = res.data.sum
					this.all_num = res.data.total
				}
			},
			//数据列表
			async loadData() {
				uni.showLoading({
					title: '加载中'
				});
				const userinfo = uni.getStorageSync('userinfo');
				const {
					data: res
				} = await this.$myHttp5({
					url: 'Datas/getTranDetail5',
					data: {
						page: this.page,
						page_size: 15,
						product_id: this.product_id,
						date: this.date,
						type: this.type,
						search: this.search,
						team_id: this.team_id,
						tran_type: this.tran_type
					},
					header: {
						'token': userinfo.token
					},
				});
				uni.hideLoading()
				if (res.code == 1) {
					this.data = res.data
				} else {
					// this.bottom = false
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #f3f4f6;
	}

	.screen_box {
		padding: 30rpx 50rpx;
		box-sizing: border-box;

		.screen_option {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin: 30rpx 0;

			text {
				background-color: #eee;
				border: #eee 1px solid;
				padding: 10rpx 20rpx;
				color: #333;
				border-radius: 100rpx;
				display: flex;
				align-items: center;
				justify-content: center;
			}

			text.on {
				background-color: #eee;
				border: #55aaff 1px solid;
				padding: 10rpx 20rpx;
				color: #55aaff;
				border-radius: 100rpx;
				display: flex;
				align-items: center;
				justify-content: center;
			}

			input {
				border: #eee 1px solid;
				border-radius: 100px;
				padding: 10rpx 30rpx;
				text-align: center;
				width: 30%;
			}
		}
	}

	.btn {
		display: flex;
		align-items: center;

		text {
			width: 50%;
			padding: 30rpx 0;
			text-align: center;
		}

		text:nth-child(1) {
			background-color: #eee;
		}

		text:nth-child(2) {
			background-color: #55aaff;
			color: #fff;
		}
	}

	.search {
		padding: 30rpx;
		box-sizing: border-box;
		background-color: #fff;
	}

	.sticky_screen {
		display: flex;
		align-items: center;
		justify-content: space-evenly;
		padding-bottom: 20rpx;

		text {
			background-color: #55aaff;
			color: #fff;
			border-radius: 100rpx;
			padding: 10rpx 20rpx;
			font-size: 24rpx;
		}
	}

	.detailed_box {
		padding: 20rpx;
		box-sizing: border-box;
		display: flex;
		flex-direction: column;

		.detailed_card {
			padding: 30rpx;
			border-radius: 15rpx;
			box-shadow: 7px 0px 30px -18px #888888;
			margin-bottom: 30rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			// background-color: #fff;
			background: url('@/static/total_bgimg.png') no-repeat center;

			.detailed_card_title {
				color: #ffffff;
				display: flex;
			}

			.card {
				font-size: 28rpx;
				color: #ffffff;
			}

			h2 {
				font-weight: 500;
				font-size: 42rpx;
				margin: 20rpx 0;
				color: #ffffff;
			}
		}

		.detailed_list {
			border-radius: 15rpx;
			margin-bottom: 30rpx;
			display: flex;
			flex-direction: column;

			.detailed_item {
				padding: 30rpx;
				box-shadow: 7px 0px 30px -18px #888888;
				margin-bottom: 30rpx;
				background-color: #fff;

				view {
					display: flex;
					justify-content: space-between;
					align-items: center;
					margin-bottom: 20rpx;
					color: #333;
					font-size: 32rpx;
				}

				.detailed_item_text {
					font-size: 24rpx;
					color: #666;
					padding-top: 20rpx;
				}
			}

			.detailed_item:last-child {
				margin-bottom: 0;
				border-bottom: none;
			}
		}
	}
</style>